
(import (scheme base)
        (turtle simple))

(define (scissor dist phase)
  (right phase)
  (forward dist)
  (left (* 2 phase))
  (forward dist)
  (right phase))

(define (scissor-poly d a phase)
  (let loop ((total-turning 0))
    (unless (and (positive? total-turning)
                 (zero? (modulo total-turning 360)))
      (scissor d phase)
      (left a)
      (loop (+ total-turning a)))))

(define (deform-scissor-poly d a phasechange)
  (let loop ((phase 0))
    (clear-screen)
    (scissor-poly d a phase)
    (loop (+ phase phasechange))))

(define (crazy-scissor-poly d a local-phasechange)
  (define local-phase 0)
  (repeat (10)
    (scissor d (modulo local-phase 360))
    (left a)
    (set! local-phase (+ local-phase local-phasechange))))

(define (main)
  ;(deform-scissor-poly 100 144 20)
  (set-pos 0 0)
  (clear-screen)
  (crazy-scissor-poly 100 150 50))

